using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class StartOrEnd : MonoBehaviour
{
    public GameObject color_eff;
    private bool canexit;
    public GameObject end;
    public bool canRest;
    // Start is called before the first frame update
    void Start()
    {
        canexit = false;
    }


    // Update is called once per frame
    void Update()
    {
        if(canexit)
        {
         if (Input.GetKeyDown(KeyCode.O))
            {
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
            }
        }
        if(canRest==true)
        {
            if (Input.GetKeyDown(KeyCode.K))
            {
                SceneManager.LoadScene("Start");
            }

        }
    }

    public void startgame()
    {
        SceneManager.LoadScene("Level");
    }

    public void Ending()
    {
        end.SetActive(true);
            creatColor(13);
            creatColor(-16);
            creatColor2(-10);
            creatColor2(11);
        canexit = true;



    }

    void creatColor(int num)
    {
        GameObject gameObject = Instantiate(color_eff);
        gameObject.transform.position = transform.position + transform.right * num;
    }
    void creatColor2(int num)
    {
        GameObject gameObject = Instantiate(color_eff);
        gameObject.transform.position = transform.position + transform.forward * num;
    }
}
